{% macro userInfo(user, isMe, isMeFollow, atCount) %}

<div class="user-info">
  <div class="user-title">
    <img src="{{user.avatar}}" width="60" height="60" style="border-radius:50%">
    <span> {{user.nickName}}</span>
  </div>
  {% if isMe %}
  <a href="/atMe">@提到我的（{{atCount}}）</a>
  {% else %}
  {% if isMeFollow %}
  <button class="unfollow">取消关注</button>
  {% else %}
  <button class='follow'>关注</button>
  {% endif %}
  {% endif %}
</div>

<script>

  // 关注
  $('.follow').click(function () {
    // 获取被关注人的id followerId
    const followerId = '{{user.id}}';
    ajax.post(
      "/api/profile/follow",
      { followerId },
      function (err, data) {
        if (err) {
          alert(err);
          return;
        }
        alert("关注成功！")
        // 刷新页面
        location.href = "";
      }
    )
  })

  // 取消关注
  $('.unfollow').click(function () {
    // 获取被关注人的id followerId
    const followerId = '{{user.id}}';
    ajax.post(
      "/api/profile/unFollow",
      { followerId },
      function (err, data) {
        if (err) {
          alert(err);
          return;
        } 5
        alert("取消关注成功！")
        // 刷新页面
        location.href = "";
      }
    )
  })
</script>
{% endmacro %}